package com.myway.dto.flight;

import com.myway.dto.flight.domain.TripType;
import com.myway.dto.order.domain.Inventory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import java.util.Date;

public class ConnectingFlightSearchCriteria {

	private static final Log log = LogFactory.getLog(ConnectingFlightSearchCriteria.class);

	public static final int INDIVIDUAL = 0;
	public static final int GROUP = 1;

	private int type;
	private String orgCity;
	private String dstCity;
	private Date date;
	private TripType tripType = TripType.MULTIWAY;
	private String airlineCode;
	private int index; // Required for individual flight search
	private Inventory inventory; // Optional for individual flight search
	private int passengerCount; // Required for group flight search

	private ConnectingFlightSearchCriteria(int type) {
		super();
		this.type = type;
	}

	public static ConnectingFlightSearchCriteria getInstanceForIndividual() {
		return new ConnectingFlightSearchCriteria(INDIVIDUAL);
	}

	public static ConnectingFlightSearchCriteria getInstanceForGroup() {
		return new ConnectingFlightSearchCriteria(GROUP);
	}

	public boolean validate() {
		boolean valid = true;

		if (type == INDIVIDUAL) {
			if (index < 0) {
				valid = false;
				log.error("Index value for connecting flight search criteria cannot be less than 0");
			}
		} else {
			if (passengerCount <= 0) {
				valid = false;
				log.error("Passenger count for connecting flight search criteria cannot be less than or equals to 0");
			}
		}

		return valid;
	}

	public int getType() {
		return type;
	}

	public void setType(int type) {
		this.type = type;
	}

	public String getOrgCity() {
		return orgCity;
	}

	public void setOrgCity(String orgCity) {
		this.orgCity = orgCity;
	}

	public String getDstCity() {
		return dstCity;
	}

	public void setDstCity(String dstCity) {
		this.dstCity = dstCity;
	}

	public Date getDate() {
		return date;
	}

	public void setDate(Date date) {
		this.date = date;
	}

	public TripType getTripType() {
		return tripType;
	}

//	public void setTripType(TripType tripType) {
//		this.tripType = tripType;
//	}

	public String getAirlineCode() {
		return airlineCode;
	}

	public void setAirlineCode(String airlineCode) {
		this.airlineCode = airlineCode;
	}

	public int getIndex() {
		return index;
	}

	public void setIndex(int index) {
		this.index = index;
	}

	public Inventory getInventory() {
		return inventory;
	}

	public void setInventory(Inventory inventory) {
		this.inventory = inventory;
	}

	public int getPassengerCount() {
		return passengerCount;
	}

	public void setPassengerCount(int passengerCount) {
		this.passengerCount = passengerCount;
	}

}
